home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / zenonew.arc / ZENO.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-11-16  |  12.4 KB  |  351 lines

  1. page 66,132
  2. page
  3. ;  X:0
  4. ;
  5. ; ZENO:  June 11, 1986
  6. ;
  7. ;   Modified Sept 4, 1986 by R Tansky to fix 40-character mode
  8. ;   Modified Oct 31, 1986 by R Tansky to further fix 40-character mode
  9. ;           and to fix graphics mode
  10. ;
  11. cseg    segment para public 'code'
  12. zeno            proc  far
  13.         assume  cs:cseg, ds:cseg, es:cseg, ss:cseg
  14.         org     100h            ; for .COM file
  15. ;
  16. environment     equ   2Ch
  17. command         equ   80h
  18. slashk          equ   'K/'
  19. slashk2         equ   'k/'
  20. ;
  21. ;-------------------------------
  22. ; enter here on initial load
  23. ;-------------------------------
  24. ;
  25. start:
  26. ;
  27.         jmp     near ptr load_pgm
  28. ;
  29. video_vector    dd   0
  30. core_seg        dw   0
  31. ;
  32. bios_cursor_posn  label  dword
  33. bios_ofst       dw   00h        ; offset for active page
  34.                 dw   40h        ; segment for bios data
  35.  
  36. ;
  37. crt_mode        db   2          ; passes if 4, 5, or 6
  38. active_page     db   0
  39. cursor_type     dw   0B0Ch      ; DOS cursor
  40. ;
  41. video_posn      label  dword
  42. video_ofst      dw     0        ; offset against video_seg
  43. video_seg       dw     0
  44. ;
  45. video_addr      dw     0
  46. ;
  47. onesixty        db   160
  48. ;
  49. ;-------------------------------
  50. ; enter here from int 10h
  51. ;-------------------------------
  52. ;
  53. video_int:
  54.         sti                     ; interrupts on
  55.         pushf                   ; save flags
  56.         cmp     cs:crt_mode,7   ; check for b/w
  57.         je      video_keep      ; go if b/w
  58.         cmp     ah,0            ; to set mode
  59.         je      route_set_mode
  60.         cmp     cs:crt_mode,4   ; check for graphics
  61.         jnc     video_exit      ; go if graphics
  62.         cmp     cs:crt_mode,1   ; check for 40-cols
  63.         jng     video_exit      ; go if 40-col
  64. video_keep:
  65.         cmp     ah,2            ; to set cursor
  66.         je      set_cursor
  67.         cmp     ah,10           ; to write char only
  68.         je      write_char
  69.         cmp     ah,9            ; to write char/attr
  70.         je      route_write_both
  71.         cmp     ah,3            ; to read cursor
  72.         je      route_read_cursor
  73.         cmp     ah,1            ; to set type
  74.         je      route_set_type
  75.         cmp     ah,0            ; to set mode
  76.         je      route_set_mode
  77.         cmp     ah,5            ; to set page
  78.         je      route_set_page
  79.         cmp     ax,0FF00h       ; kill code
  80.         je      route_do_kill   ; go if found
  81. video_exit:
  82.         popf                    ; restore flags
  83.         jmp     cs:dword ptr video_vector ; hand off interrupt
  84. ;
  85. route_write_both:
  86.         jmp     write_both
  87. ;
  88. route_read_cursor:
  89.         jmp     read_cursor
  90. ;
  91. route_set_page:
  92.         jmp     set_page
  93. ;
  94. route_set_type:
  95.         jmp     set_type
  96. ;
  97. route_set_mode:
  98.         jmp     set_mode
  99. ;
  100. route_do_kill:
  101.         jmp     do_kill
  102. ;
  103. write_char:
  104.         cmp     bh,cs:active_page ; check page
  105.         jne     video_exit      ; pass to bios
  106.         cmp     cx,1            ; for multiple write
  107.         jne     video_exit      ; pass to bios
  108.         push    di              ; save
  109.         push    es              ; save
  110.         les     di,cs:video_posn ; get screen position
  111.         cld                     ; frontwards
  112.         stosb                   ; dump to screen
  113.         pop     es              ; restore
  114.         pop     di              ; restore
  115.         popf                    ; restore flags
  116.         iret                    ; done
  117. ;
  118. set_cursor:
  119.         cmp     bh,cs:active_page ; check page
  120.         jne     video_exit      ; pass to bios
  121.         push    ax              ; save
  122.         push    cx              ; save
  123.         push    dx              ; save
  124.         push    di              ; save
  125.         push    es              ; save
  126.         add     cs:video_ofst,2 ; for next char
  127.         les     di,cs:bios_cursor_posn ; get bios
  128.         inc     byte ptr es:[di] ; assume next
  129.         cmp     es:[di],dx      ; check if next
  130.         je      offset_ready    ; go if next
  131.         mov     ax,dx           ; get req posn
  132.         mov     es:[di],ax      ; save req posn
  133.         mov     cx,ax           ; copy posn
  134.         mov     al,ah           ; rows in al
  135.         mul     cs:onesixty     ; for bytes
  136.         xor     ch,ch           ; cols in cx
  137.         shl     cx,1            ; for video
  138.         add     ax,cx           ; offset in ax
  139.         mov     cs:video_ofst,ax ; store offset
  140. offset_ready:
  141.         mov     cx,cs:video_ofst ; offset in cx
  142.         shr     cx,1            ; for byte count
  143.         mov     ah,14           ; cursor MSB register
  144.         mov     dx,cs:video_addr ; 6845 index addr
  145.         mov     al,ah           ; get register
  146.         out     dx,al           ; send register
  147.         inc     dx              ; 6845 data addr
  148.         mov     al,ch           ; get cursor MSB
  149.         out     dx,al           ; send cursor MSB
  150.         dec     dx              ; 6845 index addr
  151.         mov     al,ah           ; cursor MSB register
  152.         inc     al              ; cursor LSB register
  153.         out     dx,al           ; send register
  154.         inc     dx              ; 6845 data addr
  155.         mov     al,cl           ; get cursor LSB
  156.         out     dx,al           ; send cursor LSB
  157.         pop     es              ; restore
  158.         pop     di              ; restore
  159.         pop     dx              ; restore
  160.         pop     cx              ; restore
  161.         pop     ax              ; restore
  162.         popf                    ; restore flags
  163.         iret                    ; done
  164. ;
  165. route_video_exit:
  166.         jmp     video_exit
  167. ;
  168. write_both:
  169.         cmp     bh,cs:active_page ; check page
  170.         jne     route_video_exit ; pass to bios
  171.         cmp     cx,1            ; check multiple write
  172.         jne     route_video_exit ; pass to bios
  173.         push    ax              ; save
  174.         push    di              ; save
  175.         push    es              ; save
  176.         mov     ah,bl           ; get attribute
  177.         les     di,cs:video_posn ; get screen position
  178.         cld                     ; frontwards
  179.         stosw                   ; dump to screen
  180.         pop     es              ; restore
  181.         pop     di              ; restore
  182.         pop     ax              ; restore
  183.         popf                    ; restore flags
  184.         iret                    ; done
  185. ;
  186. read_cursor:
  187.         cmp     bh,cs:active_page ; check page
  188.         jne     route_video_exit ; pass to bios
  189.         push    di              ; save
  190.         push    es              ; save
  191.         les     di,cs:bios_cursor_posn ; get bios
  192.         mov     dx,es:[di]      ; get bios posn
  193.         mov     cx,cs:cursor_type ; get type
  194.         pop     es              ; restore
  195.         pop     di              ; restore
  196.         popf                    ; restore flags
  197.         iret                    ; done
  198. ;
  199. set_page:
  200.         push    ax              ; save
  201.         mov     cs:active_page,al ; save page
  202.         xor     ah,ah           ; page in ax
  203.         shl     ax,1            ; for word count
  204.         add     ax,50h          ; offset for page zero
  205.         mov     cs:bios_ofst,ax ; save offset
  206.         pop     ax              ; restore
  207.         jmp     video_exit      ; pass to bios
  208. ;
  209. set_type:
  210.         mov     cs:cursor_type,cx ; save type
  211.         jmp     video_exit      ; pass to bios
  212. ;
  213. set_mode:
  214.         mov     cs:crt_mode,al  ; save mode
  215.         mov     cs:video_ofst,0 ; top left
  216.         jmp     video_exit      ; done
  217. ;
  218. ; remove routine from memory
  219. ;
  220. do_kill:
  221.         mov     ax,cs           ; get code segment
  222.         mov     ds,ax           ; set data segment
  223.         mov     es,ax           ; set extra segment
  224.         push    ds              ; save
  225.         mov     ax,2510h        ; to set video vector
  226.         lds     dx,video_vector ; get original
  227.         int     21h             ; set vector
  228.         pop     ds              ; restore
  229.         mov     ah,49h          ; for free memory fn
  230.         int     21h             ; do free memory
  231.         push    es              ; save
  232.         mov     bx,environment  ; get env. segment
  233.         mov     es,cs:[bx]
  234.         mov     ah,49h          ; for free memory fn
  235.         int     21h             ; do free memory
  236.         pop     es              ; restore
  237.         lea     dx,kill_msg     ; get message
  238.         mov     ah,9            ; for screen write
  239.         int     21h             ; do write
  240.         popf                    ; restore flags
  241.         iret                    ; return to ZENO/K
  242. ;
  243. kill_msg        db   13,10,'ZENO Removed',13,10,'$'
  244. ;
  245. end_core:
  246. ;
  247. ;-------------------------------
  248. ; enter here to load program
  249. ;-------------------------------
  250. ;
  251. load_pgm:
  252. ;
  253. ; check for color screen; set video segment
  254. ;
  255.         mov     video_seg,0B000h ; assume mono
  256.         mov     video_addr,03B4h ; assume mono
  257.         int     11h             ; for equip check
  258.         and     ax,30h          ; isolate adapter
  259.         cmp     ax,30h          ; check for mono
  260.         je      mono_screen     ; go if found
  261.         mov     video_seg,0B800h ; reset for color
  262.         mov     video_addr,03D4h ; reset for color
  263. mono_screen:
  264. ;
  265. ; check command line
  266. ;
  267.         mov     si,command      ; get command line
  268.         mov     al,cs:[si]      ; length of argument
  269.         or      al,al           ; check for zero
  270.         je      command_clear   ; go if zero
  271.         cmp     al,2            ; for kill request
  272.         jne     retry           ; go if not
  273.         cmp     word ptr cs:[si+1],slashk2 ; check for '/k'
  274.         je      killme          ; go if not
  275.         cmp     word ptr cs:[si+1],slashk ; check for '/K'
  276.         jne     retry           ; go if not
  277. killme: mov     ax,0FF00h       ; set for kill
  278.         int     10h             ; order kill
  279.         int     20h             ; exit to DOS
  280. retry:
  281.         lea     dx,retry_msg    ; get message
  282.         mov     ah,9            ; for print fn
  283.         int     21h             ; print message
  284.         int     20h             ; exit to DOS
  285. command_clear:
  286. ;
  287. ; find and set current variables
  288. ;
  289.         les     di,bios_cursor_posn ; set to 0040:0000
  290.         mov     al,es:[di+49h]  ; get current mode
  291.         mov     crt_mode,al     ; save mode
  292.         mov     ax,es:[di+60h]  ; get cursor type
  293.         mov     cursor_type,ax  ; save type
  294.         mov     al,es:[di+62h]  ; get active page
  295.         mov     active_page,al  ; save active page
  296.         xor     ah,ah           ; page in ax
  297.         shl     ax,1            ; for word count
  298.         add     ax,50h          ; offset for page zero
  299.         mov     bios_ofst,ax    ; save offset
  300. ;
  301. ; set video interrupt
  302. ;
  303.         mov     core_seg,cs     ; set core segment
  304.         push    es              ; save
  305.         mov     ax,3510h        ; to get vector
  306.         int     21h             ; get vector
  307.         mov     word ptr video_vector,bx ; store offset
  308.         mov     word ptr video_vector+2,es ; store segment
  309.         pop     es              ; restore
  310.         mov     ax,2510h        ; to set video vector
  311.         lea     dx,video_int    ; get offset; ds OK
  312.         int     21h             ; set vector
  313. ;
  314. ; print messages; terminate and stay resident
  315. ;
  316.         lea     dx,install_msg  ; get message
  317.         mov     ah,9h           ; for print fn
  318.         int     21h             ; print message
  319.         cmp     video_seg,0B000h ; check for mono
  320.         je      skip_message    ; go if mono
  321.         lea     dx,color_msg    ; get message
  322.         mov     ah,9h           ; for print fn
  323.         int     21h             ; print message
  324. skip_message:
  325.         lea     dx,finish_msg   ; get termination
  326.         mov     ah,9h           ; for print fn
  327.         int     21h             ; print ternination
  328.         lea     ax,end_core     ; last address in core
  329.         add     ax,2Fh          ; make bumper
  330.         mov     cl,4            ; for shift
  331.         shr     ax,cl           ; convert to paras
  332.         mov     bx,ax           ; no. paras to keep
  333.         mov     dx,ax           ; same
  334.         mov     ah,4Ah          ; for setblock
  335.         int     21h             ; do setblock
  336.         mov     ax,3100h        ; for keep; no exit code
  337.         int     21h             ; exit and stay resident
  338. ;
  339. install_msg     db   13,10,'ZENO 1.1 successfully Installed$'
  340. ;
  341. color_msg       db   ';',13,10,'May cause some snow.$'
  342. ;
  343. finish_msg      db   13,10,'$'
  344. ;
  345. retry_msg       db   13,10,'No Action:  Invalid Command Line',13,10,7,'$'
  346. ;
  347. zeno            endp
  348. cseg            ends
  349.         end     start
  350.  
  351.